﻿#region Namespaces

using System.Xml;

using Vibstudio.X4NET.IO.Path;
using Vibstudio.X4NET.Test.Util;
using Vibstudio.X4NET.Xml.Comparision;

using Microsoft.VisualStudio.TestTools.UnitTesting;

#endregion

namespace Vibstudio.X4NET.Test
{
    [TestClass]
    public class XmlComparisionTests
    {
        private const string SOURCE_FILE_NAME = "SampleEng1.xml";
        private const string CHANGED_FILE_NAME = "SampleEng2.xml";
        private const string RESULT_COMPARISON_FILE_NAME = "OutcomeSampleEng.xml";

        private readonly FilePath _sourceFile = IOHelper.ComposeSampleFilePath(SOURCE_FILE_NAME);
        private readonly FilePath _changedFile = IOHelper.ComposeSampleFilePath(CHANGED_FILE_NAME);
        private readonly FilePath _resultComparisonFile = IOHelper.ComposeSampleFilePath(RESULT_COMPARISON_FILE_NAME);

        public TestContext TestContext { get; set; }

        [TestMethod]
        public void XmlDiif()
        {
            bool identical;
            using (XmlWriter resultComparisonWriter = XmlWriter.Create(_resultComparisonFile.Path))
            {
                XmlDiff xmlDiff = new XmlDiff(XmlDiffOptions.IgnoreChildOrder | XmlDiffOptions.IgnoreNamespaces);
                identical = xmlDiff.Compare(_sourceFile.Path, _changedFile.Path, false, resultComparisonWriter);
            }

            Assert.IsTrue(identical);
        }
    }
}